from urllib.parse import quote, unquote

import requests

# url = 'http://www.example.com/search?'
# query = 'python urllib'
# url_encoded = f'{url}q={quote(query)}'
#
# print(url_encoded)  # http://www.example.com/search?q=python+urllib
#
# url_decoded = f'{url}q={unquote(url_encoded.split("=")[-1])}'
#
# print(url_decoded)  # http://www.example.com/search?q=python urllib

# https://uc.dlysjg.td.gd.gov.cn/positionalInfo/track/api/apiGpsListNew?
# vehicleNo=%E7%B2%A4AJU189&
# vehicleColorName=%E9%BB%84%E8%89%B2&
# startDate=2024-09-07+00:00:00&
# endTime=2024-09-08+01:07:27&
# deviceCode=013306347826&type=2&
# abnormalType=1&
# runState=
print(unquote('%E7%B2%A4AJU189'))
print(unquote('%E9%BB%84%E8%89%B2'))
print(quote('黄色'))




# headers = {'Authorization':'Bearer 88a68716-a4c8-4a0e-ae69-48f7adb20be5','TENANT-ID':'6','User-Agent': ''}
headers = {'Authorization':'Bearer 88a68716-a4c8-4a0e-ae69-48f7adb20be5','TENANT-ID':'6','User-Agent': ''}
r = requests.request('POST', "https://uc.dlysjg.td.gd.gov.cn/positionalInfo/track/api/apiGpsListNew?vehicleNo=%E7%B2"
                             "%A4AJU189&vehicleColorName=%E9%BB%84%E8%89%B2&startDate=2024-09-07+00:00:00&endTime"
                             "=2024-09-08+01:07:27&deviceCode=013306347826&type=2&abnormalType=1&runState=",
                     headers = headers)
print(r.url)
print(r.request.headers)
print(r.status_code)
data = r.json()
print(data)
